<template>
  <div class="hot">
    <v-showTitle :titleImg='titleImg'></v-showTitle>
    <div class="hot-wrapper">
      <!-- <div class="ad">
                <ul class="ad-wrapper">
                    <li class="ad-item" v-for="(v, i) in lists" :key="i">
                        <div class="img">
                            <img :src="v.url" alt="">
                        </div>
                        <div class="name"><span>{{v.name}}</span></div>
                    </li>
                </ul>
            </div> -->
      <div class="ad" @click="_skipADDetail(ad.isClick, ad.goodsSkuId)">
        <img :src="ad.advertiseImg" width="100%" alt="">
      </div>
      <!-- <div class="loot">
                <div class="loot-item">
                    <img :src="loot1" width="100%" alt="">
                </div>
                <div class="loot-item">
                    <img :src="loot2" width="100%" alt="">
                    <img :src="loot3" class="img" width="100%" alt="">
                </div>
            </div> -->
      <ul class="goods">
        <li class="item" v-for="(v, i) in goods" :key="i" @click="_skipDetail(v.goodsSkuId)">
          <div class="img">
            <img :src="v.goodsLogo" width="100%" alt="">
          </div>
          <div class="name">{{v.goodsName}}</div>
          <div class="price now">
            <!--<span class="text">当前价</span>-->
            <span class="num">￥{{v.platformRetailPrice}}</span>
            <span class="text old">￥{{v.marketRetailPrice}}</span>
          </div>
          <div class="endTime">
            <span class="text">描述:</span>
            <span class="text desc">{{v.remark}}</span>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
  import showTitle from './showTitle'
  import CountDown from '@c/countDown/countDown'
  import loot1 from '@imgs/home/goods/g7.png'
  import loot2 from '@imgs/home/goods/g8.png'
  import loot3 from '@imgs/home/goods/g9.png'
  import {
    getSustemTime,
    getCurrentTime,
    doCountDown,
    countDown,
  } from '@js/until.js'
  import { formatDate } from '@js/formatDate.js'
  import { vpost, sonpost, fpost, gpost, vlink } from '@api/axios'
  import { Connect } from '@api/apiUrl'
  import { tokenPost, jtpost, gtpost, tokenLink, jtget } from '@api/axiosByToken'
  export default {
    name: 'Hot',
    data() {
      return {
        titleImg: 'hotsell',
        loot1,
        loot2,
        loot3,
        ad: {}, //广告位置
        goods: [],
      }
    },
    methods: {
      // 获得广告图片
      _getAd() {
        let adData = {
          addLocation: 0,
        }
        vpost(vlink.home.ad, adData).then(re => {
          if (re.status === 0) {
            this.ad = re.data
          } else if (re.status === -1) {
            return
          } else {
            this.$Message.warning(re.msg)
          }
        })
      },
      // 点击广告跳转详情页
      _skipADDetail(typeId, goodId) {
        if (typeId === 1) {
          return
        } else {
          this.$router.push({
            path: 'dealDetail',
            name: 'DealDetail',
            query: {
              id: goodId,
            },
          })
        }
      },
      // 获得热销产品列表
      _getHot() {
        let hotInfo = {
          offset: 0,
          limit: 10,
        }
        vpost(vlink.home.hot, hotInfo).then(re => {
          if (re.status === 0) {
            this.goods = re.data
          } else {
            this.$Message.warning(re.msg)
          }
        })
      },
      // 跳转产品详情页
      _skipDetail(id) {
        this.$router.push({
          name: 'DealDetail',
          path: '/dealDetail',
          query: {
            id: id,
          },
        })
      },
    },
    mounted() {
      this._getHot()
      this._getAd()
    },
    components: {
      'v-showTitle': showTitle,
      'count-down': CountDown,
    },
  }
</script>
